import { lazy } from 'react';
import { RouteObject } from 'react-router-dom';
import AuthWrapper from '@/components/AuthWrapper';
import RxLazy from '@/components/RxLazy';

const Cart = lazy(() => import('@/pages/Cart'));
const Dynamic = lazy(() => import('@/pages/Dynamic'));
const Home = lazy(() => import('@/pages/Home'));
const Login = lazy(() => import('@/pages/Login'));
const Message = lazy(() => import('@/pages/Message'));
const NotFound = lazy(() => import('@/pages/NotFound'));
const SearchPage = lazy(() => import('@/pages/Search'));
const UserPage = lazy(() => import('@/pages/UserPage'));
const GoodsPage = lazy(() => import('@/pages/Goods'));
const OrderPage = lazy(() => import('@/pages/Order'));
const OrderDetail = lazy(() => import('@/pages/Order/OrdersDetail'));
const OrdersResult = lazy(() => import('@/pages/Order/OrdersResult'));

export default [
  {
    path: '/',
    element: (
      <RxLazy>
        <Home />
      </RxLazy>
    ),
  },
  {
    path: '/cart',
    element: (
      <RxLazy>
        <AuthWrapper>
          <Cart />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '/dynamic',
    element: (
      <RxLazy>
        <AuthWrapper>
          <Dynamic />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '/user_page',
    element: (
      <RxLazy>
        <AuthWrapper>
          <UserPage />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '/message',
    element: (
      <RxLazy>
        <AuthWrapper>
          <Message />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '/login',
    element: (
      <RxLazy>
        <Login />
      </RxLazy>
    ),
  },
  {
    path: '/search',
    element: (
      <RxLazy>
        <SearchPage />
      </RxLazy>
    ),
  },
  {
    path: '/user_page/:id',
    element: (
      <RxLazy>
        <AuthWrapper>
          <UserPage />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '/goods_detail/:id',
    element: (
      <RxLazy>
        <GoodsPage />
      </RxLazy>
    ),
  },
  {
    path: '/orders',
    element: (
      <RxLazy>
        <AuthWrapper>
          <OrderPage />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '/orders_detail/:id',
    element: (
      <RxLazy>
        <AuthWrapper>
          <OrderDetail />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '/orders_result',
    element: (
      <RxLazy>
        <AuthWrapper>
          <OrdersResult />
        </AuthWrapper>
      </RxLazy>
    ),
  },
  {
    path: '*',
    element: (
      <RxLazy>
        <NotFound />
      </RxLazy>
    ),
  },
] as RouteObject[];
